﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UnitLibrary.GameObjects.PowerUpEffects;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace UnitLibrary.Managers
{
    public class PowerUpEffects: Manager, IManager
    {
        public PowerUpEffects(Game game, ComponentM components): base(game, components)
        { _powerUps = new LinkedList<IPowerUp>();
        _removePowerUp = new Queue<IPowerUp>();}

        

        private LinkedList<IPowerUp> _powerUps;
        private Queue<IPowerUp> _removePowerUp;

        public void LoadContent()
        { 

        }
        public void Apply(string typeofpowerup, string name)
        {
            IPowerUp powerUp = new DoNothing();
            if (typeofpowerup == typeof(GodMode).Name)
            {
                powerUp = new GodMode();
                powerUp.Create(null, this._components);
            }
            else if (typeofpowerup == typeof(HealthPack).Name)
            {
                powerUp = new HealthPack();
                powerUp.Create(null, this._components);
            }
            this._powerUps.AddLast(powerUp); 
        }

        public void Update(GameTime gameTime)
        {
            foreach (IPowerUp powerup in _powerUps)
                powerup.Update(gameTime);
            while (_removePowerUp.Count != 0)
                _powerUps.Remove(_removePowerUp.Dequeue());
        }
        public void Draw(SpriteBatch spriteBatch)
        { }

        private void Remove(IPowerUp powerUp)
        {
            _removePowerUp.Enqueue(powerUp);
        }
    }
}
